import 'package:flutter/material.dart';
import 'package:flutter_framework/constant/color_res.dart';
import 'package:flutter_framework/theme/theme_ctrl.dart';
import 'package:flutter_framework/theme/theme_item.dart';
import 'package:flutter_framework/extens/style_ext.dart';

class TestTheme extends StatefulWidget {
  const TestTheme({super.key});

  @override
  TestThemeState createState() => TestThemeState();
}

class TestThemeState extends State<TestTheme> {
  final ThemeCtrl themeCtrl = ThemeCtrl.to;

  @override
  Widget build(BuildContext context) {
     final theme = Theme.of(context);
    return Scaffold(
      appBar: AppBar(
        title: Text('模板'),
      ),
      body: Center(
          child: Column(
        children: [
          Text(
            'textColor: ${themeCtrl.themeItem.connerColor}',
            style: TextStyle(color: themeCtrl.themeItem.connerColor),
          ),
          Text(
            '当前主题色:${ theme.scaffoldBackgroundColor}',
            style:TextStyle(color: ColorRes.primaryColor),
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              TextButton(
                  onPressed: () {
                    themeCtrl.changeTheme(ThemeEnum.dark);
                  },
                  child: Text(
                    '深色主题，dark',
                  )),
              TextButton(
                  onPressed: () {
                    themeCtrl.changeTheme(ThemeEnum.light);
                  },
                  child: Text('浅色主题，light'))
            ],
          )
        ],
      )),
    );
  }
}
